from openai import OpenAI
import json

client = OpenAI(api_key="0",base_url="http://0.0.0.0:8080/v1")

# 读取json文件
with open('/home/llama/llamafactory-examples/train_cf/data/大西瓜籽妈妈.deepseek.chat.json', 'r') as f:
    data = json.load(f)

# 处理每条数据
for item in data:
    messages = [{"role": "user", "content": item["output"]}]
    result = client.chat.completions.create(messages=messages, model="/data2/modelscope/hub/models/saves/20250620-121434/full/sft/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B")
    
    # 根据result结果添加tags
    if "TRUE" in result.choices[0].message.content:
        item["tags"] = "##个人经历##"
    else:
        item["tags"] = "##其他##"
    
    print(result.choices[0].message)

# 保存修改后的数据
with open('/home/llama/llamafactory-examples/train_cf/data/大西瓜籽妈妈.deepseek.chat.cf.json', 'w') as f:
    json.dump(data, f, ensure_ascii=False, indent=4)